package com.xq.jltx.learnopenglandroidpro.tutorial.lesson5;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLSurfaceView;

import com.xq.jltx.learnopenglandroidpro.R;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

/**
 * @author jltxseo
 * Created by junlintianxia on 2018/10/14.
 */
public class TutorialLessonFiveRenderer implements GLSurfaceView.Renderer {
    private Context context;

    public TutorialLessonFiveRenderer(Context context) {
        this.context = context;
    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        TutorialLessonFiveNative.nativeOnSurfaceCreate(context.getResources().getAssets());
        TutorialLessonFiveNative.setBitmap(getBitmap());
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        TutorialLessonFiveNative.nativeOnSurfaceChange(width,height);
    }

    @Override
    public void onDrawFrame(GL10 gl) {
        TutorialLessonFiveNative.nativeOnDrawFrame();
    }

    public Bitmap getBitmap(){
        Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.first);
        return bmp;
    }

}
